// index.js
import request from '../../request/request.js'

Page({
  data: {
   swiperList:[],
   cardList:[],
   courseList:[],
   albumList:[],
   coachList:[]
  },
  onLoad: function(option){
    this.getCardList();
    this.getSwiperList();
    this.getCourseList();
    this.getAlbumList();
    this.getCoachList();
  },
  getSwiperList(){
    request({
      url:'system/swiper'
    }).then(res=>{
      this.setData({
        swiperList:res.data.data
      })
    }).catch(err=>{})
  },
  getCardList(){
    request({
      url:'card/list',
      method:'post'
    }).then(res=>{
      this.setData({
        cardList:res.data.data.slice(0,2)
      })
    }).catch(err=>{})
  },
  getCourseList(){
    request({
      url:'course/list',
      method:'post'
    }).then(res=>{
      this.setData({
        courseList:res.data.data.slice(0,4)
      })
    }).catch(err=>{})
  },
  getAlbumList(){
    request({
      url:'system/album/list'
    }).then(res=>{
      this.setData({
        albumList:res.data.data.slice(0,2)
      })
    }).catch(err=>{})
  },
  getCoachList(){
    request({
      url:'coach/list',
      method:'post'
    }).then(res=>{
      this.setData({
        coachList:res.data.data.slice(0,4)
      })
    }).catch(err=>{})
  }
})
